$import( "SmitearWebGL.Objects.Parser.Collada.DaeEntity" );
$import( "SmitearWebGL.Objects.Parser.Collada.DaeSkin" );
$import( "SmitearWebGL.Objects.Parser.Collada.DaeMorph" );

SmitearWebGL.Objects.Parser.Collada.DaeController = SmitearWebGL.Objects.Parser.Collada.DaeEntity.extend(
{
	/******** constructor ********/

	init : function( document, node )
	{
		this.type = 0;
		this.skin = null;
		this.morph = null;

		this._super( document, node );
		this._registClass( "SmitearWebGL.Objects.Parser.Collada.DaeController" );
	}
	,
	
	/******** public method ********/
	
	read : function( node )
	{
		$THROW( node.localName == SmitearWebGL.Objects.Parser.Collada.Const.DAE_CONTROLLER_ELEMENT,
		"expected a '" + SmitearWebGL.Objects.Parser.Collada.Const.DAE_CONTROLLER_ELEMENT + "' element" );

		this._super( node );

		$LOG( "reading controller: " + this.id );

		// <skin> or <morph>
		var skinNode = this.getNode( node, SmitearWebGL.Objects.Parser.Collada.Const.DAE_CONTROLLER_SKIN_ELEMENT );
		if( skinNode )
		{
			this.skin = new SmitearWebGL.Objects.Parser.Collada.DaeSkin(this.document, skinNode );
			this.type = SmitearWebGL.Objects.Parser.Collada.DaeController.TYPE_SKIN;
		}
		else
		{
			// ok, must be a morph!
			var morphNode = this.getNode(node, SmitearWebGL.Objects.Parser.Collada.Const.DAE_CONTROLLER_MORPH_ELEMENT);
			if( morphNode )
			{
				this.morph = new SmitearWebGL.Objects.Parser.Collada.DaeMorph(this.document, morphNode );
				this.type = SmitearWebGL.Objects.Parser.Collada.DaeController.TYPE_MORPH;
			}
		}

		if( !this.skin && !this.morph )
		$THROW( false, "controller element should contain a <skin> or a <morph> element!" );

		if( this.type == SmitearWebGL.Objects.Parser.Collada.DaeController.TYPE_SKIN )
		{
			//this.skin.joints.inputs
		}
		else
		{

		}
	}
}
);

SmitearWebGL.Objects.Parser.Collada.DaeController.TYPE_SKIN = 0;
SmitearWebGL.Objects.Parser.Collada.DaeController.TYPE_MORPH = 1;